package hu.dynamicwebshop.shacoder;

import java.io.Serializable;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author Szecskó Zoltán <zoltan.szecsko@gmail.com>
 */
public class SHACoder implements Serializable {

    private static final long serialVersionUID = 1L;

    public String encode(String password) {
        String shaCode = null;
        try {
            MessageDigest sha = MessageDigest.getInstance("SHA-1");
            sha.reset();
            sha.update(password.getBytes());
            shaCode = new BigInteger(1, sha.digest()).toString(16);
        } catch (NoSuchAlgorithmException ex) {
            //Logger.getLogger(ShaKodolo.class.getName()).log(Level.SEVERE, null, ex);
        }
        return shaCode;
    }
}
